package com.longxi.gamer_base.dialog;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.longxi.gamer_base.R;
import com.longxi.gamer_base.widget.CustomDialog;

/**
 * Created by cxw on & 2018/10/12
 */
public class WaitDialog {
    private CustomDialog mDialogWaiting;
    private Context context;
    public WaitDialog(Context context) {
        this.context = context;
    }

    /**
     * 显示等待提示框
     */
    public Dialog showWaitingDialog(String tip) {
        hideWaitingDialog();
        View view = View.inflate(context, R.layout.dialog_waiting, null);
        if (!TextUtils.isEmpty(tip))
            ((TextView) view.findViewById(R.id.tvTip)).setText(tip);
        mDialogWaiting = new CustomDialog(context, view, R.style.MyDialog);
        mDialogWaiting.show();
        return mDialogWaiting;
    }

    /**
     * 隐藏等待提示框
     */
    public void hideWaitingDialog() {
        if (mDialogWaiting != null) {
            mDialogWaiting.dismiss();
        }
    }
}
